package com.lljin.study.userserviceprovider.controller;

import com.lljin.study.client.OrderServiceFeignClient;
import com.lljin.study.client.UserServiceFeignClient;
import com.lljin.study.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lljin
 * @description TODO
 * @date 2020/7/13 23:13
 */
@RestController
@RefreshScope
public class UserController implements UserServiceFeignClient {
    private final UserService userService;
    private final OrderServiceFeignClient orderService;
    @Value("${greet}")
    private String greet;

    public UserController(UserService userService, OrderServiceFeignClient orderService) {
        this.userService = userService;
        this.orderService = orderService;
    }

    @Override
    public String user(String name) {
        return greet + " " + userService.getUserByName(name);
    }

    @Override
    public String userOrder(String userId) {
        return "user id "+ userId + "order:"+orderService.order("100");
    }

}
